package com.example.administrator.dc.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.dc.Bean.MyfollowDatas;
import com.example.administrator.dc.R;
import com.example.administrator.dc.helper.RoundImageView;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by Administrator on 2017/8/29.
 */

public class MyFollowAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
        {
            private Context mContext;
            private List mDataList;
            public LayoutInflater mLayoutInflater;


            public MyFollowAdapter(Context mContext , List mDataList){
                this. mContext=mContext;
                this.mDataList=mDataList;


            }

            @Override
            public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                View v = LayoutInflater.from(mContext).inflate(R.layout.cardview_myfollow, parent, false);
                return new ViewHolder(v);
            }

            @Override
            public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {

                final MyfollowDatas entity = (MyfollowDatas) mDataList.get(position);
                if (null == entity)
                    return;
                final MyFollowAdapter.ViewHolder viewHolder = (MyFollowAdapter.ViewHolder) holder;
                viewHolder.username.setText(entity.getAliasname());
                viewHolder.userschool.setText(entity.getSchool());
                if (!"".equals(entity.getFollowpic()))
                {
                    Picasso.with(mContext).load(entity.getFollowpic()).into(viewHolder.userphoto);
                }




            }


            @Override
            public int getItemCount() {
                return mDataList.size();
            }
            public class ViewHolder extends RecyclerView.ViewHolder {
                private ImageView  img_isfollow;
                private RoundImageView userphoto;
                private TextView username,userschool,tv_isfollow;

                public ViewHolder(View itemView) {
                    super(itemView);

                    userphoto= (RoundImageView)itemView.findViewById(R.id.myfollow_userpohot);
                    img_isfollow=(ImageView)itemView.findViewById(R.id.myfollow_img_isfollow);
                    username=(TextView)itemView. findViewById(R.id.myfollow_username);
                    userschool=(TextView)itemView.findViewById(R.id.myfollow_userschool);
                    tv_isfollow=(TextView)itemView.findViewById(R.id.myfollow_tv_isfollow);
                }
            }





        }
